package com.ks.app.admin.util;

import java.util.List;
 public class PageView { 
/** 分页数据 **/ 
 private List records;
    /** 页码�?��索引和结束索�?**/ 
   private PageIndex pageindex;
     /** 总页�?**/
    private long totalpage = 1;
    /** 每页显示记录�?**/
     private int maxresult = 20;
  /** 当前�?**/
    private int currentpage = 1;
    /** 总记录数 **/
    private long totalrecord=0;
     /** 页码数量 **/
  private int pagecode = 3;
    /** 要获取记录的�?��索引 **/
   public int getFirstResult() {
    return (this.currentpage-1)*this.maxresult;
     }
   public int getPagecode() {
         return pagecode;
    }
   public void setPagecode(int pagecode) {
        this.pagecode = pagecode;
    }
   public PageView(){}
    public PageView(int maxresult, int currentpage) {
         this.maxresult = maxresult;
      this.currentpage = currentpage;
     }
   public void setQueryResult(QueryResult qr){
        setTotalrecord(qr.getTotalrecord());
        setRecords(qr.getResultlist());
     }
   
     public long getTotalrecord() {
         return totalrecord;

         
     }
    public void setTotalrecord(long totalrecord) {
      this.totalrecord = totalrecord;
        setTotalpage(this.totalrecord%this.maxresult==0? this.totalrecord/this.maxresult : this.totalrecord/this.maxresult+1);
    }
     public List  getRecords() {
         return records;
    }
    public void setRecords(List records) {
        this.records = records;
    }
    public PageIndex getPageindex() {
        return pageindex;
    }
    public long getTotalpage() {
        return totalpage;
     }
    public void setTotalpage(long totalpage) {

        this.totalpage = totalpage;
         this.pageindex = PageIndex.getPageIndex(pagecode, currentpage, totalpage);
    }
    public int getMaxresult() {
        return maxresult;
    }
   public int getCurrentpage() {
        return currentpage;
     }
    public void setCurrentpage(int currentpage){
         this.currentpage=currentpage;
    }
 }



